export default {
    install (Vue, options) {
        Vue.prototype.$routeParam = function () {
            let fullPath = this.$route.fullPath
            if (fullPath.indexOf('?')>0&&fullPath.indexOf('=')>0) {
                let params = fullPath.split('?')[1]
                let obj = {}
                if (fullPath.indexOf('&') > 0) {
                    let p = params.split('&')
                    for(let i=0;i<p.length;i++) {
                        let a = p[i].split('=')
                        obj[a[0]] = decodeURI(a[1])
                    }
                } else {
                    let p = params.split('=')
                    obj[p[0]] = decodeURI(p[1])
                }
                if(obj.page) {
                    delete obj.page
                }
                return obj
            }
        }
        Vue.prototype.$currentPage = function (variable) {
            let href = window.location.href
            let query = href.substring(href.indexOf('?')+1);
            let vars = query.split("&");
            for (var i = 0; i < vars.length; i++) {
                let pair = vars[i].split("=");
                if (pair[0] == variable) {
                    return pair[1];
                }
            }
            return 1;
        }
    }
}
